//
//  main.m
//  04_homework_颜色处理
//
//  Created by dllo on 16/7/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "ColorManager.h"

int main(int argc, const char * argv[]) {
    
//    NSString *path = [[NSBundle mainBundle] pathForResource:@"crayons" ofType:@"txt"];
    NSString *sourceStr = [NSString stringWithContentsOfFile:@"/Users/dllo/DLS160710/Objective-C/HomeWork/04_homework_颜色处理/04_homework_颜色处理/crayons.txt" encoding:NSUTF8StringEncoding error:nil];
    NSArray *lineArr = [sourceStr componentsSeparatedByString:@"\n"];
    NSLog(@"%ld", lineArr.count);
    
    NSMutableDictionary *colorDic = [NSMutableDictionary dictionary];
    for (NSString *lineStr in lineArr) {
        NSArray *keyAndValue = [lineStr componentsSeparatedByString:@" #"];
        // 数组最后有一个空行
        if (keyAndValue.count == 2) {
            [colorDic setObject:keyAndValue[1] forKey:keyAndValue[0]];
        }
    }
//    NSLog(@"%@", colorDic);
    ColorManager *colorManager = [[ColorManager alloc] initWithDictionary:[NSMutableDictionary dictionary]];
    [colorManager sortColor:colorDic];
    
    NSLog(@"%@", colorManager.colorSorts);
    
    return 0;
}
